// 数组去重

function bySet (list) {
  // return [...new Set(list)]
  return Array.from(new Set(list))
}

function byindexOf (list) {
  let arr = []
  list.forEach(item => {
    if (arr.indexOf(item) === -1) {
      arr.push(item)
    }
  })
  return arr
}

function byIncludes (list) {
  let arr = []
  list.forEach(item => {
    if (!arr.includes(item)) {
      arr.push(item)
    }
  })
  return arr
}

function byhasOwnProperty (list) {
  var obj = {}
  return list.filter((item, index, arr) => {
    console.log(obj)
    return obj.hasOwnProperty(typeof item + item) ? false : (obj[typeof item + item] = true)
  })
}

function byReduce (list) {
  return list.reduce((prev, cur) => prev.includes(cur) ? prev : [...prev, cur],[])
}

function byFIlter (list) {
  return list.filter((item, index, arr) => {
    return arr.indexOf(item, 0) === index
  })
}
function byMap (arr) {
  let map = new Map();
  let array = new Array();  // 数组用于返回结果
  for (let i = 0; i < arr.length; i++) {
    if(map.has(arr[i])) {  // 如果有该key值
      map.set(arr[i], true); 
    } else { 
      map.set(arr[i], false);   // 如果没有该key值
      array.push(arr[i]);
    }
  } 
  return array ;
}
function bySort (list) {
  list = list.sort()
  var arrry= [list[0]];
  for (var i = 1; i < list.length; i++) {
    if (list[i] !== list[i-1]) {
        arrry.push(list[i]);
    }
}
return arrry;
}
